import matplotlib.pyplot as plt
import string
import time
import datetime
import numpy
import sqlite3
import time

con = sqlite3.connect('/home/ben/fridge.db', detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
con.row_factory = sqlite3.Row
cur = con.cursor()
timestamps = list()
temps = list()

td = datetime.timedelta(-4)
yn = datetime.datetime.now() + td


cur.execute('select * from data order by time ASC')
for row in cur:
  t = time.mktime(row['time'].timetuple())
  timestamps.append(t)
  temps.append(row['temperature'])

timestamps = [(t-timestamps[0])/(60*60) for t in timestamps]
slopes = numpy.diff(temps[::6])*10
plt.plot(timestamps, temps)#, timestamps[::6][:-1], slopes)
plt.show()



